import { defineStore } from "pinia";
import { getHomeSuggests, getHomeCategories, getHomelists } from "@/service";
const useHomeStore = defineStore("home", {
  state: () => ({
    hotSuggests: [],
    categories: [],
    houseList: [],
    currentPage: 1,
  }),
  actions: {
    async getHomeSuggestsAction() {
      const result = await getHomeSuggests();
      this.hotSuggests = result.data;
    },
    async getHomeCategoriesAction() {
      const result = await getHomeCategories();
      this.categories = result.data;
    },
    async getHomelistsAction() {
      const result = await getHomelists(this.currentPage);
      this.houseList.push(...result.data);
      this.currentPage++;
    },
  },
});
export default useHomeStore;
